<%@ Page Language="VB" MasterPageFile="~/Default.master" Strict="false" Title="Untitled Page" ValidateRequest="false" %>


<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="~/UserControls/LoginBanner.ascx" %>
<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="~/UserControls/ImageThumbnail.ascx" %>
<%@ Register TagPrefix="Club" TagName="Photopicker" Src="~/UserControls/photos_formpicker.ascx" %>
<%@ Register TagPrefix="Club" TagName="Durationpicker" Src="~/UserControls/Durationpicker.ascx" %>
<%@ Register TagPrefix="Club" TagName="Locationpicker" Src="~/UserControls/Locations_picker.ascx" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Session("FCKeditor:UserFilesPath") = Request.ApplicationPath.ToString & "Files/"
        If Not IsPostBack Then
            Photopicker1.ImageId = Nothing
            dtpicker.startDateTime = Now
            dtpicker.endDateTime = Now.AddHours(3)
            staticURLTextBox.Enabled = False
        End If
    End Sub

    Protected Sub apply1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim description As String = ""
        If FCKeditor1.Value.ToString() = "" Then
            description = "<p></p>"
        Else
            description = FCKeditor1.Value.ToString()
        End If
        
        Dim locationname As String
        If IsDBNull(LocationNameTXT.Text) Then
            locationname = ""
        Else
            locationname = LocationNameTXT.Text
        End If
        
        Dim pictureid As Integer
        'If IsDBNull(Photopicker1.ImageId) Then
        'pictureid = 5
        ' Else
        pictureid = Photopicker1.ImageId
        'End If
        
        Dim maxattn As Integer
        If txtMaxAttendees.Text.ToString() = "" Then
            maxattn = 0
        Else
            maxattn = CInt(txtMaxAttendees.Text.ToString())
        End If
                
        
        Dim URL As String = ""
        If CheckBox1.Checked = True Then
            URL = staticURLTextBox.Text.ToString()
        End If
        
        Dim locdirections As String
        If FCKeditor2.Value.ToString() = "" Then
            locdirections = "<p></p>"
        Else
            locdirections = FCKeditor2.Value.ToString()
        End If
        
        ClubStarterKit.Data.ClubEvent.Insert(dtpicker.startDateTime, dtpicker.endDateTime, titleTextBox.Text.ToString(), description, URL, pictureid, 0, chkRSVP1.Checked, maxattn, 0, LocationNameTXT.Text, locdirections)
        Response.Redirect("list.aspx")
    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If CheckBox1.Checked = True Then
            staticURLTextBox.Enabled = True
        Else
            staticURLTextBox.Enabled = False
        End If
    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="body">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
        <Club:LoginBanner ID="LoginBanner1" runat="server" />
        <div class="fullwidth">
            <h3>Add Event</h3>
            <div class="dashedline">
            </div>
            <table>
                        <tr>
                            <td class="formlabel">
                                Event Heading:
                            </td>
                            <td align="left">
                                <asp:TextBox ID="titleTextBox" runat="server" Width="500px" Text=""></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="titleTextBox"
                                    ErrorMessage="Please Enter a Heading." ValidationGroup="add" ToolTip="Please Enter a Heading.">*</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Link:
                            </td>
                            <td align="left">
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" Text="Use a link instead of inline content for this anouncement:" OnCheckedChanged="CheckBox1_CheckedChanged" /><br />
                                    Link:
                                    <asp:TextBox runat="server" ID="staticURLTextBox"
                                        Width="450px" Enabled="False" />
                                </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Location Name:
                            </td>
                            <td align="left">
                                <asp:TextBox ID="LocationNameTXT" runat="server" Width="500px" Text=""></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Location Description:
                            </td>
                            <td align="left">
<FCKeditorV2:FCKeditor ID="FCKeditor2" runat="server" ToolbarSet="Default" SkinPath="skins/office2003/"
                                    Value="" BasePath="~/FCKeditor/" UseBROnCarriageReturn="true">
                                </FCKeditorV2:FCKeditor>                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                <asp:Label ID="Label1" runat="server" Text="Description:" />
                            </td>
                            <td align="left">
                                <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" ToolbarSet="Default" SkinPath="skins/office2003/"
                                    Value="" BasePath="~/FCKeditor/" UseBROnCarriageReturn="true">
                                </FCKeditorV2:FCKeditor>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FCKeditor1"
                                    ErrorMessage="Please Enter a Description." ValidationGroup="add" EnableClientScript="False" ToolTip="Please Enter a Heading.">*</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Event Date:</td>
                            <td align="left">
                                <Club:Durationpicker ID="dtpicker" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Photo:</td>
                            <td align="left">
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                <Club:Photopicker ID="Photopicker1" runat="server" />
                                </ContentTemplate>
                            </asp:UpdatePanel>
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel">
                                Want online sign-ups?</td>
                            <td align="left">
                                <asp:CheckBox runat="server" Checked="false" ID="chkRSVP1" />
                            </td>
                        </tr>
                        <tr>
                            <td class="formlabel" style="height: 67px">
                                Maximum attendees:<br />
                                (For Unlimited, type -1)
                            </td>
                            <td style="height: 67px">
                                <asp:TextBox ID="txtMaxAttendees" runat="server" Width="50px" Text="" ></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                    <div class="dashedline">
                    </div>
                    <div class="actionbuttons">
                        <Club:RolloverButton ID="apply1" Text="Add Event" runat="server" ValidationGroup="add" OnClick="apply1_Click" />
                        <Club:RolloverLink ID="Cancel" Text="Cancel" runat="server" NavigateURL="Calendar.aspx" />
                    </div>
        </div>
</div>
</asp:Content>

